<%! func View(w http.ResponseWriter,r *http.Request,task model.Task) error %>

<%% import "github.com/infinitbyte/framework/modules/ui/common" %%>
<%% import "github.com/infinitbyte/gopa/model" %%>
<%% import  "github.com/infinitbyte/framework/core/i18n" %%>
<%% import "net/http" %%>

<% common.Head(w, "Task","") %>
<link rel="stylesheet" href="/static/assets/css/tasks.css" />
<script src="/static/assets/js/jquery.timeago.js"></script>
<script src="/static/assets/js/page/tasks.js"></script>
<script src="/static/assets/uikit-2.27.1/js/components/pagination.min.js"></script>

<% common.Body(w) %>
<% common.Nav(w,r,"Tasks") %>
<style>
     strong{
        margin-right: 10px;;
    }
</style>
<div class="tm-middle">

    <div class="uk-container uk-container-center">

        <div class="uk-grid" data-uk-grid-margin="">

            <div class="tm-main uk-width-medium-3-4">
                <div class="uk-overflow-container">
                    <div class="tm-middle-header">
                        <div class="uk-grid " data-uk-grid-margin="">
                            <div class="uk-width-1-1">
                                <h2><%=i18n.GetLocalizedText("Task")%></h2>
                            </div>
                        </div>
                    </div>

                    <div class="p"><strong><%=i18n.GetLocalizedText("ID")%>:</strong><%= task.ID%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Host")%>:</strong><%= task.Host%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Url")%>:</strong><%= task.Url%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("OriginalUrl")%>:</strong><%= task.OriginalUrl%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Reference")%>:</strong><%= task.Reference%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Status")%>:</strong><%= model.GetTaskStatusText(task.Status)%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Depth")%>:</strong><%= task.Depth%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Breadth")%>:</strong><%= task.Breadth%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Created")%>:</strong><%= task.Created%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("Updated")%>:</strong><%= task.Updated%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("LastFetch")%>:</strong><%= task.LastFetch%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("LastCheck")%>:</strong><%= task.LastCheck%></div>
                    <div class="p"><strong><%=i18n.GetLocalizedText("NextCheck")%>:</strong><%= task.NextCheck%></div>


                    <div class="p"><strong><%=i18n.GetLocalizedText("PipelineConfigID")%>:</strong><%= task.PipelineConfigID%></div>

                    <div class="p"><strong><%=i18n.GetLocalizedText("Message")%>:</strong><%= task.Message%></div>

                </div>

                <hr />

                <div>
                    <div class="tm-middle-header">
                        <div class="uk-grid " data-uk-grid-margin="">
                            <div class="uk-width-1-1">
                                <h2><%=i18n.GetLocalizedText("Snapshot")%>(<%= task.SnapshotCount%>)</h2>
                            </div>
                        </div>
                        <div class="uk-grid grid-margin">
                            <div>
                                <div class="p"><strong><%=i18n.GetLocalizedText("SnapshotVersion")%>:</strong><%= task.SnapshotVersion%></div>
                                <div class="p"><strong><%=i18n.GetLocalizedText("SnapshotID")%>:</strong><%= task.SnapshotID%></div>
                                <div class="p"><strong><%=i18n.GetLocalizedText("SnapshotHash")%>:</strong><%= task.SnapshotHash%></div>
                                <div class="p"><strong><%=i18n.GetLocalizedText("SnapshotSimHash")%>:</strong><%= task.SnapshotSimHash%></div>
                                <div class="p"><strong><%=i18n.GetLocalizedText("SnapshotCreated")%>:</strong><%= task.SnapshotCreated%></div>
                            </div>
                        </div>
                    </div>
                    <div class="tm-middle-body">
                        <div class="uk-overflow-container">
                            <table class="uk-table uk-table-hover border">
                                <thead>
                                <tr>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("#")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Created")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Size")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Version")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Hash")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Title")%></th>
                                    <th class="uk-text-center"><%=i18n.GetLocalizedText("Action")%></th>
                                </tr>
                                </thead>
                                <tbody>
                                <% for i,v:=range task.Snapshots {%>
                                <tr class="uk-text-center">
                                    <td><%= i%></td>
                                    <td><%= v.Created%></td>
                                    <td><%= v.Size%></td>
                                    <td><%= v.Version%></td>
                                    <td><%= v.Hash%></td>
                                    <td><%= v.Title%></td>
                                    <td><a class="uk-button uk-button-small uk-button-primary" target="_blank" href="/snapshot/<%= v.ID%>">View</a></td>
                                </tr>
                                <%}%>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tm-sidebar uk-width-medium-1-4 uk-hidden-small uk-row-first">
                <% if task.LastScreenshotID !="" { %>
                    <ul class="tm-nav uk-nav" data-uk-nav="">
                        <h2><%=i18n.GetLocalizedText("Screenshot")%></h2>
                    </ul>
                    <img style="max-width: 100%" src="/screenshot/<%= task.LastScreenshotID %>" />
                <% } %>
            </div>
        </div>
        </div>

</div>

<% common.Footer(w) %>
